﻿@{
    ViewBag.Title = "操作日志";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
<div class="row">
    <div class="col-md-12">
        <div class="box box-primary">
            <div class="box-header with-border">
                <h3 class="box-title">操作日志列表</h3>
                <div class="box-tools">
                    <div class="input-group" style="width: 250px;">
                        <input type="text" class="form-control input-sm" placeholder="请输入名称进行模糊查询...">
                        <div class="input-group-btn">
                            <a class="btn btn-sm btn-default"><i class="fa fa-search"></i></a>
                        </div>
                    </div>
                </div>
            </div>
            <div class="box-body no-padding">
                <div class="mailbox-controls">
                    <div class="btn-group" id="partial_button_toolbar">
                        @{ Html.RenderPartial("~/Areas/Common/Views/Shared/_PartialButton.cshtml"); }
                    </div>
                    <a data-toggle="tooltip" title="刷新" class="btn btn-default btn-sm"><i class="fa fa-refresh">刷新</i></a>
                </div>
                <div class="mailbox-jqgrid">
                    <table id="list"></table>
                    <div id="pager"></div>
                </div>
            </div>
        </div>
    </div>
</div>

<div id="detailDiv" style="overflow: auto;display: none">
    <table class="edit-table">
        <tbody>
            <tr>
                <th>
                    操作时间：
                </th>
                <td>
                    <label id="CreateTime"></label>
                </td>
            </tr>
            <tr>
                <th>
                    描述：
                </th>
                <td>
                    <label id="Describe"></label>
                </td>
            </tr>
            <tr>
                <th>
                    登录名：
                </th>
                <td>
                    <label id="CreateUserCode"></label>
                </td>
            </tr>
            <tr>
                <th>
                    真实姓名：
                </th>
                <td>
                    <label id="CreateUserName"></label>
                </td>
            </tr>
            <tr>
                <th>
                    当前Url：
                </th>
                <td>
                    <label id="Url"></label>
                </td>
            </tr>
            <tr>
                <th>
                    上次Url：
                </th>
                <td>
                    <label id="UrlReferrer"></label>
                </td>
            </tr>
            <tr>
                <th>
                    控制器：
                </th>
                <td>
                    <label id="ControllerName"></label>
                </td>
            </tr>
            <tr>
                <th>
                    方法名称：
                </th>
                <td>
                    <label id="ActionName"></label>
                </td>
            </tr>
            <tr>
                <th>
                    请求数据：
                </th>
                <td>
                    <label id="RequestData"></label>
                </td>
            </tr>
            <tr>
                <th>
                    响应状态：
                </th>
                <td>
                    <label id="ResponseStatus"></label>
                </td>
            </tr>
            <tr>
                <th>
                    页面展示(秒)：
                </th>
                <td>
                    <label id="ResultExecutionTime"></label>
                </td>
            </tr>
            <tr>
                <th>
                    方法执行(秒)：
                </th>
                <td>
                    <label id="ActionExecutionTime"></label>
                </td>
            </tr>

            <tr>
                <th>
                    浏览器：
                </th>
                <td>
                    <label id="UserAgent"></label>
                </td>
            </tr>
            <tr>
                <th>
                    客户端IP：
                </th>
                <td>
                    <label id="ClientHost"></label>
                </td>
            </tr>

            <tr>
                <th>
                    服务端IP：
                </th>
                <td>
                    <label id="ServerHost"></label>
                </td>
            </tr>
        </tbody>
    </table>
</div>

<script type="text/javascript">
    var $grid,
        height;

    function initGird() {
        $grid = $("#list").jgridview(
        {
            loadonce: false,
            url: '/System/Log/GetPagingOperationLog',
            colModel: [
                  { name: "OperationLogId", hidden: true },
                  { label: "登录名", name: "CreateUserCode", width: 100, fixed: true },
                  { label: "真实姓名", name: "CreateUserName", width: 60, fixed: true },
                  { label: "操作时间", name: "CreateTime", width: 130, fixed: true, align: "center", formatoptions: { srcformat: 'Y-m-d H:i:s', newformat: 'Y-m-d H:i:s' }, formatter: 'date' },
                  { label: "描述", name: "Describe", width: 400 },
                  { label: "响应状态", name: "ResponseStatus", align: "center", width: 50, fixed: true },
                  { label: "页面展示(秒)", name: "ResultExecutionTime", align: "right", width: 120, fixed: true },
                  { label: "方法执行(秒)", name: "ActionExecutionTime", align: "right", width: 120, fixed: true },
                  { label: "客户端", name: "ClientHost", width: 150 }
            ],
            sortname: "CreateTime",
            height: height,
            sortorder: "desc",
            subGrid: true,
            subGridRowExpanded: function (subgridId, rowId) {
                var rowDatas = $grid.jqGrid('getRowData', rowId);
                if (typeof (rowDatas["OperationLogId"]) != "undefined") {
                    UtilAjaxPost("/System/Log/GetOperationLogById", { id: rowDatas["OperationLogId"] },
                        function (val) {
                            $("#detailDiv").find('label').each(function () {
                                var $this = $(this), id = $this.attr('id');
                                (val[id]) && $this.text(val[id]);
                            });
                        }
                    );
                } else {
                    $("#detailDiv label").html("");
                }
                $("#" + subgridId).html($("#detailDiv").html());
            }
        });
    }

    $(function () {
        height = UtilWindowHeightWidth().WinH - 319;
        initGird();
        $('#datepicker').datepicker({
            autoclose: true
        });
    });
</script>
